﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
using DataLayer.Model.Objects;
using DataLayer;

namespace BuisnessLayer
{
    public class ProfileWriter
    {
        public int Save(Profile pProfile)
        {
            try
            {
                var fs = new FileStream(Singleton.Settings.Folders.Profiles + "\\" + pProfile.Name + ".profile",
                FileMode.Create);
                var writer = XmlDictionaryWriter.CreateTextWriter(fs);
                var ser = new NetDataContractSerializer();
                ser.WriteObject(writer, pProfile);
                writer.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return 0;
        }
    }
}
